#include "SypEngine.h"

#ifdef CHECKMEM
#include "mmgr.h"
#endif

namespace Syp
{
	Button* Button::createButton(const String& name,float Width, float Height)
	{
		return (new Button(name,Width,Height));
	}


	Button::Button(const String& name,float Width, float Height):GuiBase(name,Width,Height)
	{
		text = 0;
		mat->subMaterials[0].btype = Syp::BLEND;
	


	}

	Label* Button::getLabel()
	{
		if(!text)
		{
			text = Label::createLabel(name, "Button" + name);
			text->getMIRef().bindToNode( &this->getMIRef() );
		}
		return text;
	}
	Button::~Button()
	{
		if(text)
		{
			Label::destroyGuiComponent(text);
		}

	}

	//void Button::setButtonText(const String& txt)
	//{
	//	assert(fo && "No Font has been specified for button to set Text.");
	//	if(textInst)
	//	{
	//		MeshInstance::destroyMeshInstance(textInst);
	//		textInst = 0;
	//	}
	//	text = txt;
	//	float fontW = fo->fontWidth(txt);
	//	std::cout<<"Font Widths generated for Button Text : "<<fontW<<"/n";
	//	//not vertically centered
	//	textInst = fo->generateStaticMesh(txt, (mi->getPosition().x + width/2) - fontW/2, mi->getPosition().y, mi->getPosition().z + 1.0f);
	//	textInst->bindToNode(&this->getMIRef());
	//}
	
}
